/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2011 ymnk, JCraft,Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright 
     notice, this list of conditions and the following disclaimer in 
     the documentation and/or other materials provided with the distribution.

  3. The names of the authors may not be used to endorse or promote products
     derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.yisin.ssh2.jsch;

/**
 * Usually not to be used by applications.
 * A generator for a DSA key pair.
 *<p>
 * The library contains a default implementation of this class, based on
 * the JCE classes available in Java SE from 1.4.
 *</p>
 *<p>
 * The actual implementation class is chosen by the configuration option
 * {@code "keypairgen.dsa"}, and then instantiated using the no-argument
 * constructor. The library uses each instance only for one key generation.
 *</p>
 *<p>
 * This object will create a DSA key pair, consisting of a public key
 * ({@link #getP p}, {@link #getQ q}, {@link #getG g}, {@link #getY y})
 * and a private key {@link #getX x}.</p>
 *<p>
 * Here {@code q} is a 160-bit prime (when using SHA-1),
 * {@code p} a prime of the given key size such that
 * {@code p-1} is a multiple of {@code q}, {@code g} is a generator of a
 *  multiplicative subgroup of order {@code q} of {@code (Z/pZ)^*}.
 *  {@code p}, {@code q} and {@code g} are called
 *   <em>community parameters</em> and can be shared by many keys (some
 * implementations may have precalculated ones).
 *</p>
 * <p>
 *  {@code x} is a random number with {@code 0 < x < q}, and
 *  {@code y = g^x mod p} - these two numbers are key pair specific, and
 *  {@code x} must be preserved secretely.
 * </p>
 */
public interface KeyPairGenDSA {
  /**
   * Generates a key pair.
   * The other methods can then be called to retrieve
   * the key components.
   * @param key_size  the number of bits of the key to be produced.
   */
  void init(int key_size) throws Exception;

  /**
   * The secret key {@code x}.
   */
  byte[] getX();
  /**
   * The public key {@code y = g^x mod p}.
   */
  byte[] getY();

  /**
   * The modulus {@code p}, a prime.
   */
  byte[] getP();

  /**
   * The order {@code q} of the subgroup of (Z/pZ)^* generated by {@code g},
   * also prime.
   */
  byte[] getQ();

  /**
   * The generator {@code g} of the subgroup.
   */
  byte[] getG();
}
